package com.group.elmboot.mapper;

import com.group.elmboot.po.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

	@Select("select * from user where userId=#{userId} and password=#{password}")
	public User getUserByIdByPass(User user);
	
	@Select("select count(*) from user where userId=#{userId}")
	public int getUserById(String userId);
	
	@Insert("insert into user(userId,password,userName,userSex,userImg,delTag) values(#{userId},#{password},#{userName},#{userSex},#{userImg},1)")
	public int saveUser(User user);
	
	@Update("update user set userName=#{userName},userImg=#{userImg} where userId=#{userId}")
	public int updateUser(User user);
	
	@Update("update user set validation=#{validation} where userId=#{userId}")
	public int updateValidation(int validation,String userId);
	
	@Select("select validation from user where userId=#{userId}")
	public int getValidation(String userId);
	
	@Update("update user set password=#{password} where userId=#{userId}")
	public int updatePassword(User user);
	
	@Update("update user set expirationTime = #{expirationTime}, isVIP = #{isVIP} where userId = #{userId}")
	public int updateExpirationTimeById( @Param("userId") String userId,@Param("expirationTime") String expirationTime, @Param("isVIP") int isVIP);
	
	@Select("select userId,expirationTime from user where isVIP=1")
	public List<User> getVIPUsers();
	
	@Select("select isVIP,expirationTime from user where userId=#{userId}")
	public User getVIPInfoById(String userId);
}
